package com.tql.mall.web.controller;

import com.tql.mall.item.client.ItemFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.Map;

/**
 * @Author: tyk
 * @Date: 2023/5/22 21:25
 * @Description:
 */
@Controller
public class ItemWebController {
    @Autowired
    private ItemFeignClient itemFeignClient;

    @GetMapping("{skuId}.html")
    public String getItem(@PathVariable Long skuId, Model model) {
        // 获取商品详情
        Map<String, Object> map = itemFeignClient.getItem(skuId);
        // 设置数据
        model.addAllAttributes(map);
        // 返回页面
        return "item/item";
    }
}
